package com.zyf.school.manager.domain;

import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;

import java.util.List;

@Setter
@Getter
@NoArgsConstructor
public class DepartmentTree {
    //部门转换成部门树的列表
    public static List<Tree> toTree(List<Tree> tree , List<Department> department){
        for (int i=0; i<department.size(); i++){
            Tree t = new Tree();
            t.setId(String.valueOf(department.get(i).getId()));
            t.setTitle(department.get(i).getName());
            tree.add(t);
            toTree(t.getChildren(),department.get(i).getList());
        }
        return tree;
    }
}
